<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: RandomFrequencyOnlyModel Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00185.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">RandomFrequencyOnlyModel Class Reference<div class="ingroups"><a class="el" href="a00511.html">analogueModels - AnalogueModel implementations</a> &#124; <a class="el" href="a00527.html">AnalogueModels example - Classes from the AnalogueModels example</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="RandomFrequencyOnlyModel" --><!-- doxytag: inherits="AnalogueModel" -->
<p>Sample implementation of an <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> which uses <a class="el" href="a00148.html" title="Implementation of the Mapping-interface which is able to represent arbitrary dimensional instances of...">MultiDimMapping</a> as AttenuationMapping.  
 <a href="a00185.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00232_source.html">RandomFrequencyOnlyModel.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RandomFrequencyOnlyModel:</div>
<div class="dyncontent">
<div class="center"><img src="a00974.png" border="0" usemap="#RandomFrequencyOnlyModel_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for RandomFrequencyOnlyModel:</div>
<div class="dyncontent">
<div class="center"><img src="a00975.png" border="0" usemap="#RandomFrequencyOnlyModel_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00976.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00185.html#a7f2a29b2108609ff9f1549ee74668ffc">RandomFrequencyOnlyModel</a> (int seed=23)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the analogue model.  <a href="#a7f2a29b2108609ff9f1549ee74668ffc"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00185.html#a89ed481e27038eec8dcd71c7c55437d1">initFromMap</a> (const <a class="el" href="a00009.html#ab1820eb5285a02a2464be54ec651feab">ParameterMap</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the analog model from XML map data.  <a href="#a89ed481e27038eec8dcd71c7c55437d1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00185.html#acac71950a5a7176292f7c404c32f609c">filterSignal</a> (airframe_ptr_t, const <a class="el" href="a00065.html">Coord</a> &amp;, const <a class="el" href="a00065.html">Coord</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Has to be overriden by every implementation.  <a href="#acac71950a5a7176292f7c404c32f609c"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abe40315d1e83aab5a999278cd7f2da6b"></a><!-- doxytag: member="RandomFrequencyOnlyModel::frequency" ref="abe40315d1e83aab5a999278cd7f2da6b" args="" -->
const <a class="el" href="a00085.html">Dimension</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b">frequency</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">shortcut to the frequency dimension, to avoid using 'Dimension("frequency")' every time. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a42f3ab529c90ee41904e5cc95fae5bd7"></a><!-- doxytag: member="RandomFrequencyOnlyModel::dimensions" ref="a42f3ab529c90ee41904e5cc95fae5bd7" args="" -->
const <a class="el" href="a00086.html">DimensionSet</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00185.html#a42f3ab529c90ee41904e5cc95fae5bd7">dimensions</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">stores the dimensions this analogue model applies to. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Sample implementation of an <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> which uses <a class="el" href="a00148.html" title="Implementation of the Mapping-interface which is able to represent arbitrary dimensional instances of...">MultiDimMapping</a> as AttenuationMapping. </p>
<p>This class is a sample which shows how to use the default <a class="el" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a> implementation to implement a signal attenuation over only one dimension but which is not the time. Since every <a class="el" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a> has to be defined in time we can't really create a <a class="el" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a> with only frequency as <a class="el" href="a00085.html" title="Specifies a dimension for mappings (like time, frequency, etc.)">Dimension</a>. But we can just create a two dimensional <a class="el" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a> over frequency and time which is constant in time space. This means every time we want to set a value of the <a class="el" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a> we will just pass 0 as parameter for the time dimension. </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a7f2a29b2108609ff9f1549ee74668ffc"></a><!-- doxytag: member="RandomFrequencyOnlyModel::RandomFrequencyOnlyModel" ref="a7f2a29b2108609ff9f1549ee74668ffc" args="(int seed=23)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RandomFrequencyOnlyModel::RandomFrequencyOnlyModel </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>seed</em> = <code>23</code></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes the analogue model. </p>
<p>The only thing we have to do in the constructor and which whould probably have to be done for every other <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> is setting the the <a class="el" href="a00086.html" title="Represents a set of dimensions which is used to define over which dimensions a mapping is defined (th...">DimensionSet</a> this <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> will work with.</p>
<p>In this case we want to work on "time (constant)" and "frequency". The <a class="el" href="a00086.html" title="Represents a set of dimensions which is used to define over which dimensions a mapping is defined (th...">DimensionSet</a> provides constructors for up to three initial dimensions. If we need more we will have to add them after construction by calling the DimensionSets "addDimension()"-method.</p>
<p>Note: Using "Dimension("time")" instead of "Dimension::time()" would work also, but using "Dimension::time()" saves us a string comparison and should therefore be prefered instead of using "Dimension("time")". </p>
<div class="fragment"><pre class="fragment">                                         :
    <a class="code" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b" title="shortcut to the frequency dimension, to avoid using &#39;Dimension(&quot;frequency&quot;)&#39; every time...">frequency</a>(<span class="stringliteral">&quot;frequency&quot;</span>),
    <a class="code" href="a00185.html#a42f3ab529c90ee41904e5cc95fae5bd7" title="stores the dimensions this analogue model applies to.">dimensions</a>(<a class="code" href="a00085.html#a16cb1f186dd3f48d33a4aebe948001d7" title="Shortcut to the time Dimension, same as &#39;Dimension(&quot;time&quot;)&#39;, but spares the parsing of a string...">Dimension::time</a>, <a class="code" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b" title="shortcut to the frequency dimension, to avoid using &#39;Dimension(&quot;frequency&quot;)&#39; every time...">frequency</a>) {

    <span class="comment">//sets the seed for random number generation. The PhyLayer</span>
    <span class="comment">//(which created the analogue models) gets the seed from the</span>
    <span class="comment">//configuration parameters inside the xml-config</span>
    srand(seed);
  }
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="acac71950a5a7176292f7c404c32f609c"></a><!-- doxytag: member="RandomFrequencyOnlyModel::filterSignal" ref="acac71950a5a7176292f7c404c32f609c" args="(airframe_ptr_t, const Coord &amp;, const Coord &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RandomFrequencyOnlyModel::filterSignal </td>
          <td>(</td>
          <td class="paramtype">airframe_ptr_t&#160;</td>
          <td class="paramname"><em>frame</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname">&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Has to be overriden by every implementation. </p>
<p>The actual filtering method. This implementation just put some random attenuations over time and frequency into the attenuation mapping.</p>
<p>Filters a specified AirFrame's <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a> by adding an attenuation over time to the <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>. </p>

<p>Implements <a class="el" href="a00009.html#a3242bc36a68dab53551d4ab1f1dab010">AnalogueModel</a>.</p>

<p>References <a class="el" href="a00192.html#a0beeef0f27c33145a0fca521df1c5f5c">Signal::addAttenuation()</a>, <a class="el" href="a00138.html#a0c61c76ba04339162563339b23bf42e9">MappingUtils::createMapping()</a>, <a class="el" href="a00185.html#a42f3ab529c90ee41904e5cc95fae5bd7">dimensions</a>, <a class="el" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b">frequency</a>, <a class="el" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2">Signal::getReceptionStart()</a>, <a class="el" href="a00136.html#aa713c0cd84f74727888bef5b9e8b0643ac8a952576b8d13258ba0f3c0f1584f9b">Mapping::LINEAR</a>, <a class="el" href="a00013.html#a657d962a1b965814e6b2eecb07f03e80">Argument::MappedOne</a>, <a class="el" href="a00013.html#a27bd7000e865670a673039233424d2ab">Argument::setArgValue()</a>, <a class="el" href="a00013.html#a8087982f050bdc61d787b128ca9ac8f9">Argument::setTime()</a>, and <a class="el" href="a00136.html#ab8906dfac661d5c6a0a35cf1744f06ed">Mapping::setValue()</a>.</p>
<div class="fragment"><pre class="fragment">                                                                                               {
    <a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>&amp; signal = frame-&gt;getSignal();

  <span class="comment">/* At first get a new instance of the default Mapping implementation</span>
<span class="comment">   * which is able to represent our attenuation mapping.</span>
<span class="comment">   * the first parameter of &quot;createMapping&quot; gets the DimensionSet the</span>
<span class="comment">   * Mapping should use as domain and the second parameter gets the</span>
<span class="comment">   * interpolation method to be used to calculate the values between</span>
<span class="comment">   * two Mapping entries.</span>
<span class="comment">   *</span>
<span class="comment">   * Note 1: At the moment only LINEAR interpolation is implemented.</span>
<span class="comment">   *</span>
<span class="comment">   * Note 2: For now the same interpolation method is used for</span>
<span class="comment">   * interpolation in every dimension. Later it might be possible</span>
<span class="comment">   * to define different interpolation methods for different</span>
<span class="comment">   * dimensions. For example: While linear interpolation of time</span>
<span class="comment">   * makes sence in most cases, using NEAREST whould make more sense</span>
<span class="comment">   * for frequency.</span>
<span class="comment">   */</span>
  <a class="code" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a>* attMapping = <a class="code" href="a00138.html#a0c61c76ba04339162563339b23bf42e9" title="Returns an appropriate changeable Mapping with the specified domain and the specified interpolation m...">MappingUtils::createMapping</a>(<a class="code" href="a00013.html#a657d962a1b965814e6b2eecb07f03e80" title="One value of a Argument value.">Argument::MappedOne</a>, <a class="code" href="a00185.html#a42f3ab529c90ee41904e5cc95fae5bd7" title="stores the dimensions this analogue model applies to.">dimensions</a>, <a class="code" href="a00136.html#aa713c0cd84f74727888bef5b9e8b0643ac8a952576b8d13258ba0f3c0f1584f9b" title="interpolates linear with next lower and next upper entry constant before the first and after the last...">Mapping::LINEAR</a>);

  <span class="comment">/* Get start and end of the signal to avoid unnecessary calculation</span>
<span class="comment">   * of attenuation.*/</span>
  simtime_t sStart = signal.<a class="code" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2" title="Returns the point in time when the receiving of the Signal started at the receiver module...">getReceptionStart</a>();

  <span class="comment">// Since this mapping does not depend on time, we just set values for</span>
  <span class="comment">// the first entry in time-dimension (start of the Signal)</span>
  <span class="comment">/*</span>
<span class="comment">  simtime_t sEnd = signal.getReceptionEnd();</span>
<span class="comment"></span>
<span class="comment">  simtime_t interval = 0.01; //lets use constant intervals for entries in time</span>
<span class="comment">  */</span>

  <a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a> pos(<a class="code" href="a00185.html#a42f3ab529c90ee41904e5cc95fae5bd7" title="stores the dimensions this analogue model applies to.">dimensions</a>); <span class="comment">//create an Argument which we will use as parameter</span>
                <span class="comment">//to set the values inside the mapping</span>

  pos.setTime(sStart); <span class="comment">// set arguments position in time dimension</span>

  <span class="keywordflow">for</span>(<span class="keywordtype">double</span> freq = 2.412; freq &lt; 2.465; freq += 0.01){

    pos.setArgValue(<a class="code" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b" title="shortcut to the frequency dimension, to avoid using &#39;Dimension(&quot;frequency&quot;)&#39; every time...">frequency</a>, freq*1.e9); <span class="comment">// update arguments position in frequency dimension</span>

    <span class="comment">/*</span>
<span class="comment">    //create time entries for this frequency</span>
<span class="comment">    for(simtime_t t = sStart; t &lt;= sEnd; t+=interval){</span>
<span class="comment"></span>
<span class="comment"></span>
<span class="comment">      pos.setTime(t); // update arguments position in time dimension</span>
<span class="comment">    */</span>
      <span class="comment">/* Create random attenuation between 0.1 and 1.0.</span>
<span class="comment">       * Since the attenuation value is multiplied to the transmission power mapping</span>
<span class="comment">       * it should be between 0.0 and 1.0, otherwise it whouldn&#39;t be a real</span>
<span class="comment">       * attenuation.*/</span>
      <span class="keywordtype">double</span> att = (double)rand() / (double)RAND_MAX * 0.9 + 0.1;

      attMapping-&gt;<a class="code" href="a00136.html#ab8906dfac661d5c6a0a35cf1744f06ed" title="Changes the value of the Mapping at the specified position.">setValue</a>(pos, att); <span class="comment">//put the attenuation at the current position into the mapping</span>
    <span class="comment">/*</span>
<span class="comment">    }</span>
<span class="comment">    */</span>
  }
  <span class="comment">//asure attenuation is set at end of freq range</span>
  pos.setArgValue(<a class="code" href="a00185.html#abe40315d1e83aab5a999278cd7f2da6b" title="shortcut to the frequency dimension, to avoid using &#39;Dimension(&quot;frequency&quot;)&#39; every time...">frequency</a>, 2.472e9); <span class="comment">// update arguments position in frequency dimension</span>
  <span class="keywordtype">double</span> att = (double)rand() / (double)RAND_MAX * 0.9 + 0.1;
  attMapping-&gt;<a class="code" href="a00136.html#ab8906dfac661d5c6a0a35cf1744f06ed" title="Changes the value of the Mapping at the specified position.">setValue</a>(pos, att); <span class="comment">//put the attenuation at the current position into the mapping</span>

  <span class="comment">//at last add the created attenuation mapping to the signal</span>
  signal.<a class="code" href="a00192.html#a0beeef0f27c33145a0fca521df1c5f5c" title="Adds a function representing an attenuation of the signal.">addAttenuation</a>(attMapping);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a89ed481e27038eec8dcd71c7c55437d1"></a><!-- doxytag: member="RandomFrequencyOnlyModel::initFromMap" ref="a89ed481e27038eec8dcd71c7c55437d1" args="(const ParameterMap &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool RandomFrequencyOnlyModel::initFromMap </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00009.html#ab1820eb5285a02a2464be54ec651feab">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize the analog model from XML map data. </p>
<p>This method should be defined for generic analog model initialization.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">params</td><td>The parameter map which was filled by XML reader.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the initialization was successfully. </dd></dl>

<p>Reimplemented from <a class="el" href="a00009.html#a9c52493cdf1baa4110a83869e8bc13c5">AnalogueModel</a>.</p>
<div class="fragment"><pre class="fragment">                                                                     {
    ParameterMap::const_iterator it;
    <span class="keywordtype">bool</span>                         bInitSuccess = <span class="keyword">true</span>;

    <span class="keywordflow">if</span> ((it = params.find(<span class="stringliteral">&quot;seed&quot;</span>)) != params.end()) {
        srand( ParameterMap::mapped_type(it-&gt;second).longValue() );
    }
    <span class="keywordflow">else</span> {
        <span class="comment">//bInitSuccess = false;</span>
        <span class="comment">//opp_warning(&quot;No seed defined in config.xml for RandomFreqTimeModel!&quot;);</span>
    }
    <span class="keywordflow">return</span> <a class="code" href="a00185.html#a89ed481e27038eec8dcd71c7c55437d1" title="Initialize the analog model from XML map data.">AnalogueModel::initFromMap</a>(params) &amp;&amp; bInitSuccess;
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/examples/analogueModels/<a class="el" href="a00232_source.html">RandomFrequencyOnlyModel.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/examples/analogueModels/RandomFrequencyOnlyModel.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00185.html">RandomFrequencyOnlyModel</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
